<?

//Initiate Authenticate
SecurityRedirect ();

//initiate Vars 
define("PRIMARY_KEY","kdcust");
$KEY[]         = array("PRIMARY_KEY"=>PRIMARY_KEY);
$FileName      = "ais_transaction_receipt_order.php";
$FileTemplate  = "ais_transaction_receipt_order_container.html";

$PageSize      = 10 ;
$TableName     = "$DBCoins.coins_container_process";
$HTMLGridList  = "ContainerGrid";

//************ FORM ACTION **************
	if (GetParam("Action","")=="Delete") {
		DeleteRecord ("txtCheck",$PageSize);
	}

//Initiate Database Table For Search;

$FCode = GetParam("prainref","");


$FormName = GetParam("FormName","");
//******* DATABASE FORM QUERY ***********
$SQL   = "SELECT $DBCoins.coins_container_process.crno,$DBCoins.coins_container_process.cpid,$DBCoins.tblcontainer_code.cclength,$DBCoins.coins_container_process.cpinopol,'' as phase FROM $TableName ";
$SQL  .= "INNER JOIN $DBCoins.tblprincipal ON $TableName.cpopr=$DBCoins.tblprincipal.prcode ";
$SQL  .= "INNER JOIN $DBCoins.tblcontract ON $DBCoins.tblprincipal.PRCONTRACTNO=$DBCoins.tblcontract.cono AND $DBCoins.tblprincipal.prcode=$DBCoins.tblcontract.prcode ";
$SQL  .= "INNER JOIN $DBCoins.tblcontainer ON $DBCoins.coins_container_process.crno=$DBCoins.tblcontainer.crno ";
$SQL  .= "INNER JOIN $DBCoins.tblcontainer_code ON $DBCoins.tblcontainer_code.cccode=$DBCoins.tblcontainer.cccode ";
$SQLW .= "WHERE $DBCoins.coins_container_process.cpiorderno='".GetParam("prainref","")."' ";

$SQLCount = "SELECT count(*) FROM $TableName ";
$SQL = $SQL.$SQLW;
$SQLCount = $SQLCount.$SQLW;

//$WHERE = " ifnull($DBName.ais_receipt.cpid,'')='' AND ifnull($TableName.cpiorderno,'')<>''";

$SQL .= "GROUP BY $TableName.CPIORDERNO ";

//******* SHOW FORM CONTENT *********
$PageNum = 1;
$RecCnt = $DBConnection->dbc->get_var($SQLCount) ; 

if (GetParam("PageNum","")) $PageNum  = GetParam("PageNum","");

//print $SQL;
$TBS = new clsTinyButStrong ;
$TBS->LoadTemplate($MOD_TEMPLATE_DIR."/".$FileTemplate);
$TBS->MergeBlock("bln",$KEY);
$TBS->MergeBlock("blg",$DBMysql,$SQL,$PageSize,$PageNum,$RecCnt);
$TBS->MergeNavigationBar('nv',array('size'=>10,'pos'=>'centred'),$PageNum,$RecCnt,$PageSize) ; 
$TBS->Show();


function DeleteRecord ($sequence_name,$PageSize) {
	global $DBConnection,$FileName;	
	for ($x=1;$x<=$PageSize;$x++) {		
		if (GetParam($sequence_name.$x,""))	{
			$DBConnection->Delete("tblcustomer",$sequence_name.$x);
	    }
	}
	header("Location: $FileName");
	exit;	
	
}

?>